home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2.0 - Programmer's Utilities Power Pack / Delphi 2.0 Programmer's Utilities Power Pack.iso / e_to_l / htmlview / htmlview.int < prev    next >
Encoding:
Text File  |  1996-09-15  |  4.8 KB  |  126 lines

  1. {*********************************************************}
  2. {*                     HTMLVIEW.PAS                      *}
  3. {*                 Copyright (c) 1995 by                 *}
  4. {*                   L. David Baldwin                    *}
  5. {*                 All rights reserved.                  *}
  6. {*********************************************************}
  7.  
  8. unit Htmlview;
  9.  
  10. interface
  11.  
  12. uses
  13.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  14.   Forms, Dialogs, ExtCtrls, ReadHTML, HTMLSubs;
  15.  
  16. type
  17.   THotSpotEvent = procedure(Sender: TObject; const SRC: string) of Object;
  18.   THotSpotClickEvent = procedure(Sender: TObject; const SRC: string;
  19.                      var Handled: boolean) of Object;
  20.  
  21.   TThumbScrollBox = class(TScrollBox)
  22.   private
  23.     procedure WMVScroll(var Message: TWMVScroll); message WM_VScroll;
  24.     end;
  25.  
  26.   THTMLViewer = class(TWinControl)
  27.   private
  28.     { Private declarations }
  29.     FTitle: PString;
  30.     FURL: PString;
  31.     FBase: PString;
  32.     FCurrentFile: PString;
  33.     FSectionList: TSectionList;
  34.     FNameList: TStringList;
  35.     FOnHotSpotCovered: THotSpotEvent;
  36.     FOnHotSpotClick: THotSpotClickEvent;
  37.     FOnBitmapRequest: TGetBitmapEvent;
  38.     FOnHistoryChange: TNotifyEvent;
  39.     FHistory: TStrings;
  40.     FHistoryIndex: integer;
  41.     FHistoryMaxCount: integer;
  42.     procedure ScrollResize(Sender: TObject);
  43.     procedure SetViewImages(Value: boolean);
  44.     function GetViewImages: boolean;
  45.     procedure SetColor(Value: TColor);
  46.     function GetColor: TColor;
  47.     function GetBase: string;
  48.     function GetFURL: string;
  49.     function GetTitle: string;
  50.     function GetCurrentFile: string;
  51.     procedure SetBorderStyle(Value: TBorderStyle);
  52.     function GetBorderStyle: TBorderStyle;
  53.     function GetPosition: LongInt;
  54.     procedure SetPosition(Value: LongInt);
  55.     function GetScrollPos: integer;
  56.     procedure SetScrollPos(Value: integer);
  57.     function GetScrollBarRange: integer;
  58.     procedure SetHistoryIndex(Value: integer);
  59.     procedure WMGetDlgCode(var Message: TMessage); message WM_GETDLGCODE;
  60.     procedure SetupAndLogic;
  61.   protected
  62.     { Protected declarations }
  63.     ScrollBox: TThumbScrollBox;
  64.     PaintBox: TPaintBox;
  65.     function DoLogic: integer;
  66.     function GetURL(X, Y: integer; var URL: OpenString): boolean;
  67.     procedure KeyDown(var Key: Word; Shift: TShiftState); override;
  68.     function GetPalette: HPALETTE; override;
  69.     procedure HTMLPaint(Sender: TObject); virtual;
  70.     procedure HTMLMouseDown(Sender: TObject; Button: TMouseButton;
  71.       Shift: TShiftState; X, Y: Integer); virtual;
  72.     procedure HTMLMouseMove(Sender: TObject; Shift: TShiftState; X,
  73.       Y: Integer); virtual;
  74.     procedure URLAction; virtual;
  75.     function HotSpotClickHandled: boolean; dynamic;
  76.     procedure BumpHistory(const FileName: string; OldPos: LongInt);
  77.     procedure LoadFile(const FileName: string);
  78.  
  79.   public
  80.     { Public declarations }
  81.     constructor Create(AOwner: TComponent); override;
  82.     destructor Destroy; override;
  83.     function HTMLExpandFilename(const Filename: string): string; virtual;
  84.     procedure LoadFromFile(const FileName: string);
  85.     procedure LoadStrings(Strings: TStrings);
  86.     procedure LoadFromBuffer(Buffer: PChar; BufSize: LongInt);
  87.     function PositionTo(Dest: string): boolean;
  88.     property DocumentTitle: string read GetTitle;
  89.     property URL: string read GetFURL;
  90.     property Base: string read GetBase;
  91.     property Position: LongInt read GetPosition write SetPosition;
  92.     property VScrollBarPosition: integer read GetScrollPos write SetScrollPos;
  93.     property VScrollBarRange: integer read GetScrollBarRange;
  94.     property CurrentFile: string read GetCurrentFile;
  95.     property History: TStrings read FHistory;
  96.     property HistoryIndex: integer read FHistoryIndex write SetHistoryIndex;
  97.  
  98.   published
  99.     { Published declarations }
  100.     property OnHotSpotCovered: THotSpotEvent read FOnHotSpotCovered
  101.              write FOnHotSpotCovered;
  102.     property OnHotSpotClick: THotSpotClickEvent read FOnHotSpotClick
  103.              write FOnHotSpotClick;
  104.     property OnBitmapRequest: TGetBitmapEvent read FOnBitmapRequest
  105.              write FOnBitmapRequest;
  106.     property OnHistoryChange: TNotifyEvent read FOnHistoryChange
  107.              write FOnHistoryChange;
  108.     property ViewImages: boolean read GetViewImages write SetViewImages;
  109.     property TabStop;
  110.     property TabOrder;
  111.     property Align;
  112.     property Name;
  113.     property Tag;
  114.     property Height default 150;
  115.     property Width default 150;
  116.     property Color: TColor read GetColor write SetColor default clBtnFace;
  117.     property BorderStyle: TBorderStyle read GetBorderStyle write SetBorderStyle;
  118.     property Visible;
  119.     property HistoryMaxCount: integer read FHistoryMaxCount write FHistoryMaxCount;
  120.   end;
  121.  
  122. procedure Register;
  123.  
  124. implementation
  125.  
  126.